using UnityEngine;

namespace Gj
{
    public enum ListAnimationType
    {
        All,
        Horizontal,
        Vertical
    }

    public class ListAnimationHelper : AnimationHelper
    {
        public ListAnimationType type = ListAnimationType.All;
        public bool init;
        public float width;
        public float height;

        protected override void Init()
        {
            if (init) OnUpdate(valueFrom);
            width = Rect.rect.width;
            height = Rect.rect.height;
        }

        protected override void OnUpdate(float value)
        {
            float f;
            switch (type)
            {
                case ListAnimationType.All:
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, MathTools.Lerp(0, width, value));
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MathTools.Lerp(0, height, value));
                    break;
                case ListAnimationType.Horizontal:
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, MathTools.Lerp(0, width, value));
                    break;
                case ListAnimationType.Vertical:
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MathTools.Lerp(0, height, value));
                    break;
            }
        }
    }
}